package cn.yzc.dao;

import cn.yzc.dto.TestADto;
import cn.yzc.dto.TestBDto;
import cn.yzc.vo.TestAVo;
import cn.yzc.vo.TestBVo;
import cn.yzc.vo.TestCVo;
import cn.yzc.vo.TestDVo;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.One;
import org.apache.ibatis.annotations.Param;
import yui.comn.mybatisx.annotation.Link;
import yui.comn.mybatisx.annotation.OneToMany;
import yui.comn.mybatisx.annotation.OneToOne;
import yui.comn.mybatisx.annotation.model.JoinType;
import yui.comn.mybatisx.core.conditions.Wrapper;
import yui.comn.mybatisx.core.mapper.BaseDao;

import java.util.List;

/**
 * <p>Project: mybatis-linkDemo - TestADao</p>
 * <p>Powered by yzc On 2024-05-15 10:19:18</p>
 * <p>描述：<p>
 *
 * @author yzc [youzhicheng0415@163.com]
 * @version 1.0
 * @since 17
 */
@Mapper
public interface TestADao extends BaseDao<TestAVo, TestADto> {

    /**
     * A内连A
     *
     * @param wrapper 条件构造器
     * @return
     */
    @Link(ones = {
            @OneToOne(leftColumn = "a_id", rightClass = TestAVo.class, rightAlias = "testAVo2")
    })
    List<TestADto> listTestAATestA(@Param(Constants.WRAPPER) Wrapper<TestAVo> wrapper);


    /**
     * A内连B
     *
     * @param wrapper 条件构造器
     * @return
     */
    @Link(ones = {
            @OneToOne(leftColumn = "b_id", rightClass = TestBVo.class)
    })
    List<TestADto> listTestAATestB(@Param(Constants.WRAPPER) Wrapper<TestAVo> wrapper);

    /**
     * A内连C
     *
     * @param wrapper 条件构造器
     * @return
     */
    @Link(ones = {
            @OneToOne(leftColumn = "c_id", rightClass = TestCVo.class)
    })
    List<TestADto> listTestAATestC(@Param(Constants.WRAPPER) Wrapper<TestAVo> wrapper);

    /**
     * A内连B A内连C
     *
     * @param wrapper 条件构造器
     * @return
     */
    @Link(ones = {
            @OneToOne(leftColumn = "b_id", rightClass = TestBVo.class),
            @OneToOne(leftColumn = "c_id", rightClass = TestCVo.class)
    })
    List<TestADto> listTestAATestBATestAATestC(@Param(Constants.WRAPPER) Wrapper<TestAVo> wrapper);


    /**
     * A内连B A内连C A内连D A内连A
     *
     * @param wrapper 条件构造器
     * @return
     */
    @Link(ones = {
            @OneToOne(leftColumn = "b_id", rightClass = TestBVo.class),
            @OneToOne(leftColumn = "c_id", rightClass = TestCVo.class),
            @OneToOne(leftColumn = "d_id", rightClass = TestDVo.class),
            @OneToOne(leftColumn = "a_id", rightClass = TestAVo.class, rightAlias = "testAVo2")
    })
    List<TestADto> listTestAATestBATestAATestCATestATesCATestATestAParam(@Param(Constants.WRAPPER) Wrapper<TestAVo> wrapper);

    /**
     * A左连B
     * @param wrapper 条件构造器
     * @return
     */
    @Link(ones = {
            @OneToOne(leftColumn = "b_id", rightClass = TestBVo.class, joinType = JoinType.LEFT, onArgName = "abOn")
    })
    List<TestADto> listTestALeftTestB(@Param(Constants.WRAPPER) Wrapper<TestAVo> wrapper);

    /**
     * A左连B A左连C
     * @param wrapper 条件构造器
     * @return
     */
    @Link(ones = {
            @OneToOne(leftColumn = "b_id", rightClass = TestBVo.class, joinType = JoinType.LEFT, onArgName = "abOn"),
            @OneToOne(leftColumn = "c_id",rightClass = TestCVo.class,joinType = JoinType.LEFT,
            onArgName = "acOn")
    })
    List<TestADto> listTestALeftBAndTestALeftTestC(@Param(Constants.WRAPPER) Wrapper<TestAVo> wrapper);


    /**
     * A左连B B左连C
     * @param wrapper 条件构造器
     * @return
     */
    @Link(ones = {
            @OneToOne(leftColumn = "b_id", rightClass = TestBVo.class, joinType = JoinType.LEFT, onArgName = "abOn"),
            @OneToOne(leftClass = TestBVo.class,leftColumn = "c_id",rightClass = TestCVo.class,joinType =
                    JoinType.LEFT,onArgName = "bcON")
    })
    List<TestADto> listTestALeftBAndTestBLeftTestC(@Param(Constants.WRAPPER) Wrapper<TestAVo> wrapper);


    /**
     * A右连B
     * @param wrapper 条件构造器
     * @return
     */
    @Link(ones = {
            @OneToOne(leftColumn = "b_id",rightClass = TestBVo.class,joinType = JoinType.RIGHT,onArgName = "abOn")
    })
    List<TestADto> listTestARightTestB(@Param(Constants.WRAPPER) Wrapper<TestAVo> wrapper);


    /**
     * A内连B 分页查询
     * @param page 分页条件
     * @param wrapper  条件构造器
     * @return
     */
    @Link(ones = {
            @OneToOne(leftColumn = "b_id",rightClass = TestBVo.class)
    })
    IPage<TestADto> pageTestAATestB(IPage<TestADto> page,@Param(Constants.WRAPPER)Wrapper<TestAVo> wrapper );


    /**
     * A内连B 返回符合的条数
     * @param wrapper
     * @return
     */
    @Link(ones = {
            @OneToOne(leftColumn = "b_id",rightClass = TestBVo.class)
    })
    Integer countTestAATestB(@Param(Constants.WRAPPER) Wrapper<TestAVo> wrapper);


    /**
     * A 一对多 B
     * @param wrapper 条件构造器
     * @return
     */
    @Link(manys = {
            @OneToMany(leftColumn = "b_id",rightClass = TestBVo.class,ofTypeClass = TestBDto.class,
                    property = "testBList" )}
    )
    List<TestADto> listTestAWTestB(@Param(Constants.WRAPPER) Wrapper<TestAVo> wrapper);

}
